

function TraerData(id){
    $.get("http://localhost/sysganadero/public/obtener",
        {idventa: id},
        function(data){
            var x = document.getElementById('id_ven');

            num_factura = $("#num_factura");
            fecha = $("#fecha");
            cliente = $("#cliente")
            contacto = $("#contacto");
            totalbruto =$("#total_bruto")
            num_factura.empty();
            
            cliente.empty();
            contacto.empty();
            totalbruto.empty();
            $.each(data, function(index,element){
                num_factura.append(element.num_factura);
                
                cliente.append(element.id_cliente);
                contacto.append(element.contacto);
                totalbruto.append(element.total_bruto);
                document.getElementById("id_ven").value = element.id;
            });
        
        });

}

$(function () {

    if (window.location == window.parent.location) {
        $('#back-to-bootsnipp').removeClass('hide');
        $('.alert').addClass('hide');
    } 
    
    $('#fullscreen').on('click', function(event) {
        event.preventDefault();
        window.parent.location = "http://bootsnipp.com/iframe/Q60Oj";
    });
    
    $('ver').on('click', function(event) {
        event.preventDefault();
        $('#myModal').modal('show');
    })
    
    $('.btn-mais-info').on('click', function(event) {
        $( '.open_info' ).toggleClass( "hide" );
    })
    
     
});






/**
*   I don't recommend using this plugin on large tables, I just wrote it to make the demo useable. It will work fine for smaller tables 
*   but will likely encounter performance issues on larger tables.
*
*       <input type="text" class="form-control" id="dev-table-filter" data-action="filter" data-filters="#dev-table" placeholder="Filter Developers" />
*       $(input-element).filterTable()
*       
*   The important attributes are 'data-action="filter"' and 'data-filters="#table-selector"'
*/
(function(){
    'use strict';
    var $ = jQuery;
    $.fn.extend({
        filterTable: function(){
            return this.each(function(){
                $(this).on('keyup', function(e){
                    $('.filterTable_no_results').remove();
                    var $this = $(this), search = $this.val().toLowerCase(), target = $this.attr('data-filters'), $target = $(target), $rows = $target.find('tbody tr');
                    if(search == '') {
                        $rows.show(); 
                    } else {
                        $rows.each(function(){
                            var $this = $(this);
                            $this.text().toLowerCase().indexOf(search) === -1 ? $this.hide() : $this.show();
                        })
                        if($target.find('tbody tr:visible').size() === 0) {
                            var col_count = $target.find('tr').first().find('th').size();
                            var no_results = $('<tr class="filterTable_no_results"><td colspan="'+col_count+'">No Hay Resultados en su Busqueda</td></tr>')
                            $target.find('tbody').append(no_results);
                        }
                    }
                });
            });
        }
    });
    $('[data-action="filter"]').filterTable();
})(jQuery);

$(function(){
    // attach table filter plugin to inputs
    $('[data-action="filter"]').filterTable();
    
    $('.container').on('click', '.panel-heading span.filter', function(e){
        var $this = $(this), 
                $panel = $this.parents('.panel');
        
        $panel.find('.panel-body').slideToggle();
        if($this.css('display') != 'none') {
            $panel.find('.panel-body input').focus();
        }
    });
    $('[data-toggle="tooltip"]').tooltip();
})



   $(document).ready(function(){
      var i=1;

     $("#add_row").click(function(){
      $('#addr'+i).html("<td>"+ (i+1) +"</td><td><input name='name"+i+"' type='text' placeholder='Name' class='form-control input-md' value='"+8+"' /> </td><td><input  name='mail"+i+"' type='text' placeholder='Mail'  class='form-control input-md'></td><td><input  name='mobile"+i+"' type='text' placeholder='Mobile'  class='form-control input-md'></td>");

      $('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
      i++; 
  });
     $("#delete_row").click(function(){
         if(i>1){
         $("#addr"+(i-1)).html('');
         i--;
         }
     });

});
   $("#guardar").click(function(){
    var i=1;
    var tabla = document.getElementById('dev-table');
    var celda="";
    var columna="";
    for (var i = 0; i < tabla.rows.length; i++) {
        celda = tabla.rows[i].getElementsByTagName('td');
            if(document.getElementById(i).checked){
              alert(document.getElementById(i).value);
        }
    }
    
      $('#addr'+i).html("<td>"+ (i+1) +"<td id='cod_ganado'>"+cod_ganado+"</td>");

      $('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
      i++; 
  });
function Dataselect(){
    var i=1;
    var tabla = document.getElementById('dev-table');
    var celda="";
    var columna="";
    for (var i = 0; i < tabla.rows.length; i++) {
        celda = tabla.rows[i].getElementsByTagName('td');
             if($('tr').hasClass('selected') == true){
              var a = $('td').data('field');
                 alert('hola');
            }
    }
  
    };


function Calcular(id){
    var precio = $("#precio_"+id+"").val();
    var peso = $("#peso_"+id+"").val();
    var total = $("#total_"+id+"");
    var resultado = precio * peso;
    total.val(resultado);
}
function Calculart(dato){
    var sub = $("#subtotals");
    var subt =$("#subtotals").val(); 
    var t = subt * 1;
    t += dato;
    sub.val(t);
}
/*___________________PANEL OVER_____________________*/
$(function(){
$('.bloque').hover(function(){
        $(this).find('.panel-footer').slideDown(250);
    },function(){
        $(this).find('.panel-footer').slideUp(250); //.fadeOut(205)
    });
})

/*-----------------------------Nuevo cliente------------*/
function mostrar(){
    if (document.getElementById('nuevocliente').style.display == 'none') {
        document.getElementById('nuevocliente').style.display = 'block';
        document.getElementById('cliente').disabled = 'disabled';
        document.getElementById('hay_nuevo').value = '1';
        document.getElementById('nombre').disabled = false;
        document.getElementById('ruc').disabled = false;
    }
    else{
        document.getElementById('nuevocliente').style.display = 'none';
        document.getElementById('nombre').value = '';
        document.getElementById('nombre').disabled = 'disabled';
        document.getElementById('ruc').value = '';
        document.getElementById('ruc').disabled = 'disabled';
        document.getElementById('direccion').value = '';
        document.getElementById('telefono').value = '';
        document.getElementById('email').value = '';
        document.getElementById('hay_nuevo').value = '0';
        document.getElementById('cliente').disabled = false;

    }
}

function atras() {
    window.history.back()
}